<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2018/7/23
 * Time: 14:52
 */
namespace app\jujin\controller;

use app\admin\service\SystemCateService;
use controller\JunjinAdmin;
use think\Db;
use think\view\driver\Think;

class Purchase extends JunjinAdmin
{
    public $table='Purchase';

    public function index()
    {
        $this->title = '采购管理';
        $get = $this->request->get();
        $db = Db::name($this->table);
        if (isset($get['name']) && $get['name'] !== '') {
            $db->whereLike('name', $get['name']);
        }
        return parent::_list($db->order('id desc'));
    }
    protected function _form_filter(&$data)
    {
        if($this->request->isGet()){
            if($this->request->get('id')){
                $this->title='编辑采购信息';
            }else{
                $this->title='添加采购信息';
            }
            //查询物品分类
            $this->assign('cates',Db::name('my_cate')
                ->where('pid',32)
                ->where('status',1)
                ->field('id,title')
                ->select()
            );
        }else{
            $data['grab_sheet_end_time']=strtotime($data['grab_sheet_end_time']);
        }
    }

}